#define _CRT_SECURE_NO_WARNINGS  1
#include"Stack.h"

void test()
{
	SQ stack;
	SQInit(&stack);

	SQPush(&stack, 1);
	SQPush(&stack, 2);
	SQPush(&stack, 3);
	SQPush(&stack, 4);
	SQPush(&stack, 5);
	int i = stack.top;
	while (i--)
	{
		printf("%d ", stack.arr[i]);
	}
	printf("\n");

	SQPop(&stack);
	i = stack.top;


	while (i--)
	{
		printf("%d ", stack.arr[i]);
	}
	SQPop(&stack);
	i = stack.top;

	printf("\n");

	while (i--)
	{
		printf("%d ", stack.arr[i]);
	}
	SQPop(&stack);
	i = stack.top;

	printf("\n");

	while (i--)
	{
		printf("%d ", stack.arr[i]);
	}
	SQPop(&stack);
	i = stack.top;

	printf("\n");

	while (i--)
	{
		printf("%d ", stack.arr[i]);
	}
	

	printf("\n");
	SQPop(&stack);

	i = stack.top;

	while (i--)
	{
		printf("%d ", stack.arr[i]);
	}

	printf("%d", SQTop(&stack));
	SQDestroy(&stack);
}



bool isValid(char* s) {

	char* p = s;
	SQ a;
	SQInit(&a);
	while (*p!='\0')
	{
		if (*p == '(' || *p == '[' || *p == '{')
		{
			SQPush(&a, *p);
		}
		else if (SQEmpty(&a))
			return false;
		else if (*p == ')' && SQTop(&a) != '(' || *p == ']' && SQTop(&a) != '[' || *p == '}' && SQTop(&a) != '{')
			return false;
		else
		{
			SQPop(&a);
		}
		p++;
	}
	if (!SQEmpty(&a))
		return false;
	return true;

}

void test1()
{
	SQ stack;
	SQInit(&stack);

	SQPush(&stack, 1);
	printf("%d\n", stack.arr[stack.top-1]);

	char arr[] = "[]";
	printf("%d", isValid(arr));

	SQDestroy(&stack);

}

int main()
{

	//test();
	test1();
	return 0;
}